package com.lzc.test.svc.serviceImpl;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.lzc.test.dao.BusinessUserMapper;
import com.lzc.test.entity.BusinessUser;
import com.lzc.test.entity.request.LoginRequest;
import com.lzc.test.entity.response.LoginResponse;
import com.lzc.test.svc.service.Login;

@Service
public class LoginImpl implements Login {
	
	@Resource
	BusinessUserMapper businessUserMapper;
	
	@Override
	public int login(LoginRequest loginRequest, LoginResponse loginResponse) {
		
		String username = loginRequest.getUserName();
		String password = loginRequest.getPassword();
		if (username == null || password == null) {
			return 1;
		}
		BusinessUser businessUser = businessUserMapper.selectByPrimaryKey(username);
		if (businessUser == null) {
			return 1;
		} else if(password.equals(businessUser.getPassword())) {
			// TODO 登录信息存放在session中
			return 0;
		}
		
		return 1;
	}

}
